let myImage = document.querySelector('img');
myImage.onclick = function() {
    let imgSrc = myImage.getAttribute('src')
    if (imgSrc === 'images/google.png') {
        myImage.setAttribute('src', 'images/firefox.png');
    } else {
        myImage.setAttribute('src', 'images/google.png');
    }
}

let myButton = document.querySelector('button');
let myHeading = document.querySelector('h1');

function setUserName() {
    let name = null;
    while (name === null || !name) {
        name = prompt("please input your name");
    }
    localStorage.setItem('name', name);
}

if (!localStorage.getItem('name')) {
    setUserName();
}

let name = localStorage.getItem('name');
myHeading.textContent = 'Hello, ' + name;

myButton.onclick = function() {
    setUserName();
}